import { useIntersectionObserver } from '@vueuse/core'
import defaultImg from '@/assets/images/200.png'
export default {
  install(app) {
    app.directive('imgLazy', {
      mounted(el, binding) {
        el.src = defaultImg
        console.log('imgLazy', el, binding.value)
        const { stop } = useIntersectionObserver(el, ([{ isIntersecting }]) => {
          if (isIntersecting) {
            stop()
            el.src = binding.value
          }
        }, { threshold: 0.1 })
      }
    })
  }
}
